import React, { Component, Fragment } from 'react';
import { get_Home_News } from '../../utils/biz_http.js';
import { Flex } from 'antd-mobile';

class News extends Component {
    state = {
        news: []
    }

    componentDidMount() {
        this.getNews();
    }

    async getNews() {
        let res = await get_Home_News();
        this.setState({
            news: res.data.body
        })
    }

    render() {
        return (
            <div>
                <h3 className="title">最新资讯</h3>

                {
                    this.state.news.map(item => (
                        <div className="news-item" key={item.id}>
                            <div className="imgwrap">
                                <img
                                    className="img"
                                    src={`http://157.122.54.189:9060${item.imgSrc}`}
                                    alt=""
                                />
                            </div>
                            <Flex className="content" direction="column" justify="between">
                                <h3 className="title">{item.title}</h3>
                                <Flex className="info" justify="between">
                                    <span>{item.from}</span>
                                    <span>{item.date}</span>
                                </Flex>
                            </Flex>
                        </div>
                    ))
                }

            </div>
        );
    }
}

export default News;